﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("i love my mother");
     
            //
            var localmachine = Registry.LocalMachine;
            //var windefer = localmachine.GetValue(@"SYSTEM/CurrentControlSet/Services/SecurityHealthService/start");        
            var windefer = localmachine.OpenSubKey("SYSTEM").OpenSubKey("CurrentControlSet").OpenSubKey("Services")
                .OpenSubKey("SecurityHealthService",true);
            //
            
            //Console.WriteLine("{0}", windefer.GetValue("start").ToString());
            //
            //Console.WriteLine("{0}",    "开始写注册表");
            Console.WriteLine("{0}", "启动关闭Windows Defender");
            try
            {
                windefer.SetValue("start", 4);
            }catch(Exception e)
            {
                Console.WriteLine("{0},{1}","需要权限支持",e.Message);
            }
      
            //Console.WriteLine("{0}",    "结束写注册表");
            Console.WriteLine("{0}", "结束关闭Windows Defender");
            //
            Console.ReadKey();
        }
    }
}
